package com.itheima03.day11;

import java.io.File;

/**
 * @author 刘全
 * @date 2021/7/31
 */
public class Test02 {
    public static void main(String[] args) {
        File file = new File("myideaTest");
        int count = checkJava(file);
        System.out.println(count);
    }

    static int count = 0;

    private static int checkJava(File file) {
        File[] files = file.listFiles();
        if (files != null) {
            for (File file1 : files) {
                if (file1.isFile()) {
                    if (file1.getName().endsWith(".java")) {
                        count++;
                    }
                } else {
                    checkJava(file1);
                }
            }
        }
        return count;
    }
}
